﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Fantacid303.ProcessAffinityControl.Common;
using Fantacid303.ProcessAffinityControl.Manager.Extensions;

namespace Fantacid303.ProcessAffinityControl.Manager.ValueProviders
{
	class ProcessorAffinityValueProvider
	{
		//public static List<KeyValuePair<ProcessorAffinityType, string>> GetAll()
		//{
		//    List<KeyValuePair<ProcessorAffinityType, string>> namesAndValues = new List<KeyValuePair<ProcessorAffinityType, string>>();

		//    namesAndValues.Add(new KeyValuePair<ProcessorAffinityType, string>(ProcessorAffinityType.AllCores, ProcessorAffinityType.AllCores.ToString()));

		//    if (ProcessorAffinityHelper.HasThreadingCores)
		//    {
		//        namesAndValues.Add(new KeyValuePair<ProcessorAffinityType, string>(ProcessorAffinityType.RealCores, ProcessorAffinityType.RealCores.ToString()));
		//        namesAndValues.Add(new KeyValuePair<ProcessorAffinityType, string>(ProcessorAffinityType.ThreadingCores, ProcessorAffinityType.ThreadingCores.ToString()));
		//    }

		//    namesAndValues.Add(new KeyValuePair<ProcessorAffinityType, string>(ProcessorAffinityType.Custom, ProcessorAffinityType.Custom.ToString()));

		//    return namesAndValues;
		//    /* old code
		//    List<KeyValuePair<ProcessorAffinityType, string>> namesAndValues = new List<KeyValuePair<ProcessorAffinityType, string>>();

		//    var names = Enum.GetNames(typeof(ProcessorAffinityType));
		//    var values = Enum.GetValues(typeof(ProcessorAffinityType));

		//    namesAndValues = new List<KeyValuePair<ProcessorAffinityType, string>>();

		//    int index = 0;
		//    foreach (var value in values)
		//    {
		//        namesAndValues.Add(new KeyValuePair<ProcessorAffinityType, string>((ProcessorAffinityType)value, names[index]));
		//        index++;
		//    }
		//    return namesAndValues;
		//     */
		//}
		public static List<ProcessorAffinityType> GetAll()
		{
			var values = new List<ProcessorAffinityType>();

			values.Add(ProcessorAffinityType.AllCores);

			if (ProcessorAffinityHelper.HasThreadingCores)
			{
				values.Add(ProcessorAffinityType.RealCores);
				values.Add(ProcessorAffinityType.ThreadingCores);
			}

			values.Add(ProcessorAffinityType.Custom);

			return values;
			/* old code
			List<KeyValuePair<ProcessorAffinityType, string>> namesAndValues = new List<KeyValuePair<ProcessorAffinityType, string>>();

			var names = Enum.GetNames(typeof(ProcessorAffinityType));
			var values = Enum.GetValues(typeof(ProcessorAffinityType));

			namesAndValues = new List<KeyValuePair<ProcessorAffinityType, string>>();

			int index = 0;
			foreach (var value in values)
			{
				namesAndValues.Add(new KeyValuePair<ProcessorAffinityType, string>((ProcessorAffinityType)value, names[index]));
				index++;
			}
			return namesAndValues;
			 */
		}


	}
}
